package com.icehand.learn.service.impl;

import com.icehand.learn.mybatis.mapper.product.SeasonMapper;
import com.icehand.learn.mybatis.mapper.user.ConfigMapper;
import com.icehand.learn.mybatis.model.product.Season;
import com.icehand.learn.mybatis.model.user.Config;
import com.icehand.learn.service.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Slf4j
@Service
public class DemoServiceImpl implements DemoService {
	@Autowired
	private ConfigMapper configMapper;
	@Autowired
	private SeasonMapper seasonMapper;

	@Override
	public boolean change1() {
		int count1 = configMapper.insert(new Config()
								.setAuth(1)
								.setName("testJta")
								.setValue("test")
								.setDesc("ceshi")
							);
		int count2 = seasonMapper.insert(new Season()
								.setName("test")
								.setChineseName("测试")
								.setCode("111")
								.setDateAdded(new Date())
								.setSortOrder(1)
							);
//		int i = 1/0;
		return count1 == 1 && count2 == 1;
	}

	@Override
	public boolean change2() {
		int count1 = configMapper.insert(new Config()
				.setAuth(1)
				.setName("testJta")
				.setValue("test")
				.setDesc("ceshi")
		);

		int i = 1/0;
		int count2 = seasonMapper.insert(new Season()
				.setName("test")
				.setChineseName("测试")
				.setCode("111")
				.setDateAdded(new Date())
				.setSortOrder(1)
		);

		return count1 == 1 && count2 == 1;
	}
}
